package com.stark.friendrequest;
//The purpose of this class is to show the settings fragment.

//Import the required java packages.
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

public class Settings extends Activity{
	
	//Override onCreate so that the code will run when the activity is started.
	@Override
    public void onCreate(Bundle savedInstanceState) {
        //Call to the super class.
		super.onCreate(savedInstanceState);
        
		//get the current fragment and replace the fragment with my SettingsFragment class.
        getFragmentManager().beginTransaction()
        	.replace(android.R.id.content, new SettingsFragment())
        	
        	//commit the changes so that they are saved.
        	.commit();
    }
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) 
	{	//inflate the android option_menu from XML layout
		MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.option_menu, menu);
	    return true;
	}
	
	public void goHome(){
		//Create a method to handle a button press on the menu
		Intent i = new Intent(this, MainActivity.class);
		startActivity(i);
	}
	
	public void showSettings(){
		//Create a method to handle a button press on the menu
		Intent i = new Intent(this, Settings.class);
		startActivity(i);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    // Handle item selection
	    switch (item.getItemId()) {
	        case R.id.menu_settings:
	            showSettings(); //if settings button is pressed call the goHome method
	            return true;
	        default:
	            return super.onOptionsItemSelected(item);
	    }
	}

	public void onClick(View v) {
		//not used, imported as part of the class.
	}
	
	@Override
	public void onBackPressed() {
		//handle the back button being pressed
		Intent i = new Intent(Settings.this, MainActivity.class);
		startActivity(i);
	}
}